<?php
/* 
 * Project: oCoder Framework
 * File: /models/home.php
 * Purpose: model for the home controller.
 * Author: Trung Hoang
 */

class HomeModel extends BaseModel
{
    //data passed to the home index view
    public function index()
    {   
        $diadiemdulichs = $this->find_all($table = 'view_dd_diadiemdulich', $orderby = 'SoLuotXem DESC', $where = '', $cols = '*', $limit = '6');
        $tintucmois = $this->find_all($table = 'bv_baiviet', $orderby = 'id DESC', $where = 'TuKhoaDanhMuc like "tin-tuc"', $cols = '*', $limit = '5');
        $baivietmois = $this->find_all($table = 'bv_baiviet', $orderby = 'id DESC', $where = '', $cols = '*', $limit = '7');
        $baivietxemnhieus = $this->find_all($table = 'bv_baiviet', $orderby = 'id DESC', $where = '', $cols = '*', $limit = '12');
        $amthucs = $this->find_all($table = 'bv_baiviet', $orderby = 'id DESC', $where = 'TuKhoaDanhMuc like "am-thuc"', $cols = '*', $limit = '6');
        $lehois = $this->find_all($table = 'bv_baiviet', $orderby = 'id DESC', $where = 'TuKhoaDanhMuc like "van-hoa"', $cols = '*', $limit = '6');
        $clips = $this->find_all($table = 'bv_baiviet', $orderby = 'id DESC', $where = 'TuKhoaDanhMuc like "clip"', $cols = '*', $limit = '5');
        $medias = $this->find_all($table = 'bv_baiviet', $orderby = 'id DESC', $where = 'TuKhoaDanhMuc like "clip" or TuKhoaDanhMuc like "hinh-anh"', $cols = '*', $limit = '5');
        $danhmucs = $this->find_all($table = 'bv_danhmuc', $orderby = 'iddanhmuc DESC', $where = '', $cols = '*', $limit = '');

        $this->viewModel->set("pageTitle","Trang chủ Vemientrung.com");
        $this->viewModel->set("tintucmois",$tintucmois);
        $this->viewModel->set("baivietmois",$baivietmois);
        $this->viewModel->set("amthucs",$amthucs);
        $this->viewModel->set("lehois",$lehois);
        $this->viewModel->set("clips",$clips);
        $this->viewModel->set("medias",$medias);
        $this->viewModel->set("baivietxemnhieus",$baivietxemnhieus);
        $this->viewModel->set("diadiemdulichs",$diadiemdulichs);
        $this->viewModel->set("danhmucs",$danhmucs);
        return $this->viewModel;
    }
    public function admin()
    {   
        $this->viewModel->set("pageTitle","Trang quản trị Vemientrung.com");
        return $this->viewModel;
    }
}

?>
